<template>
<div>
	<el-dialog title="调用列表" :visible.sync="dialogVisible" width="900px" @close="handleClose"
		:close-on-click-modal="false" :append-to-body="true">
		<div slot="title" class="dialog-header-title">
			<i class="el-icon-s-grid"></i>
			<span>调用列表</span>
		</div>
	
	
 	<div class=" smp_panel_1">
			<div class="smp_panel_header" >
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">查询条件</div>
			</div>
			

		<div class=" smp_panel_body"> 
		<el-form :inline="false"  label-width="80px" size="mini" ref="form" :model="query.body">
			
			<el-row>
						<el-col :span="12">
							<el-form-item label="交易码:" >
								<el-input v-model="query1.body.transCode" placeholder="交易码"></el-input>
							</el-form-item>
						</el-col>
						
						<el-col :span="12">
							<el-form-item label="交易名称:" >
								<el-input v-model="query1.body.transName" placeholder="交易名称"></el-input>
							</el-form-item>
						</el-col>
						
						<el-col :span="12">
							<el-form-item label="服务系统:" prop="regSysCode">
								<el-select v-model="query1.body.regSysCode" style="width: 100%" filterable remote
									reserve-keyword placeholder="请输入系统编号或名称" :remote-method="getsystems1"
									>
									<el-option v-for="item in systemList1" :key="item.systemNo" :label="item.systemName"
										:value="item.systemNo">
										{{ item.systemName }}({{item.systemNo}})
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						
					 <el-col :span="12" style="text-align: right;">
							<el-button  size="mini" plain type="primary" @click="onSubmit" >查询</el-button>
							<el-button size="mini" plain @click="reset" style="text-align: left;">清空</el-button>
					</el-col> 
			</el-row>
		</el-form> 
	 </div>
	</div> 
	
	<div class=" smp_panel_1">
		<div class="smp_panel_header" >
			<div class="smp_panel_pre"></div>
			<div class="smp_panel_title">调用列表</div>
		</div>
		
		<!-- <div class="detailsTitle">交易信息</div> -->
		<div class=" smp_panel_body">
		<el-table ref="listTable" :data="list" size="mini" stripe   style="width: 100%">
		<el-table-column type="selection"  label="选择"  align="center"/>
		
		<el-table-column prop="transCode" label="交易码" align="center"></el-table-column >
		<el-table-column prop="transName" label="交易名称" align="center" show-overflow-tooltip ></el-table-column>
		<el-table-column prop="pubCode" label="服务编码(P)" align="center" ></el-table-column>
		
		<el-table-column prop="regSysCode" label="服务系统" align="center" show-overflow-tooltip >
			<template slot-scope="scope">
				{{scope.row.regSysCode|getSystemName}}({{scope.row.regSysCode}})
			</template>
		</el-table-column>
		<el-table-column prop="systemNo" label="消费系统" align="center" show-overflow-tooltip>
			<template slot-scope="scope">
				{{scope.row.systemNo|getSystemName}}({{scope.row.systemNo}})
			</template>
		</el-table-column>
		<!-- <el-table-column prop="channel" label="渠道号" width="120"></el-table-column> -->
		<!-- <el-table-column prop="msgAgreement" label="消费方报文格式" align="center" width="120"></el-table-column>
		<el-table-column prop="msgCode" label="消费方字符编码" align="center" width="120">
			<template slot-scope="scope">
				{{scope.row.msgCode|dictName('SMP0004')}}
			</template>
		</el-table-column>
		
		<el-table-column prop="busCode" label="服务编码(R)" align="center" ></el-table-column>
		<el-table-column prop="proxyPath" label="ESB测试URL" align="center" show-overflow-tooltip></el-table-column>
		 -->
		<!-- <el-table-column prop="systemNo" label="服务系统"  align="center"  width="200">
		<template slot-scope="scope">
		{{scope.row.systemNo|getSystemName}}({{scope.row.systemNo}})
		</template>
		</el-table-column>
	        <el-table-column prop="busCode" label="服务编码"  align="center" />
			<el-table-column prop="transName" label="交易名称" show-overflow-tooltip="true"  align="center" />
			<el-table-column prop="transCode" label="交易码"  align="center" />
			
			<el-table-column prop="status" label="服务状态"  align="center">
				<template slot-scope="scope">
				 	{{scope.row.status|dictName("SMP0002")}}
				</template>  
			</el-table-column> -->
			
		
		</el-table>
		<div class="smp-pagination" v-show="total>0">
			<el-pagination background size="mini" layout="total,sizes,prev, pager, next,jumper" :page-size="query.pageSize" :page-sizes="[5,10,15,20]" :total="total" :current-page="query.pageNum" @current-change = "currentChange" @size-change="sizeChange">
			</el-pagination>
		</div>
	</div>
	</div> 
	
	
	
	
 	<span slot="footer" class="dialog-footer">
			<el-button size="mini" type="primary" plain @click="onCommit"><i class="el-icon-check"></i>确认</el-button>
		<el-button size="mini"  @click="closeDialog"><i class="el-icon-close"></i>取消</el-button> 
		</span> 
	</el-dialog>
</div>
</template>

<script>
	"use strict";
	import {getServiceByPage,getServiceViewDel} from '@/api/service.js';
	import {getSystemCallCheck} from '@/api/demand.js';
	
	export default {
		data() {
			return {
				total:0,
					
					type:'add',
					list: [],
					id:'',
					pubSysCode:'',
					systemNo:'',
					systemList1: [],
					query: {
						body:{
							id:'',
							pubSysCode:'',
							transCode:'',
							transName:'',
							busType:'',
							status:'',
							proposer:'',
							applyDateBegin:'',
							applyDateEnd:'',
							busCode:'',
							systemNo:''
						},
						pageNum: 1,
						pageSize: 5
					},
					
					query1: {
						body: {
							associatedRequirement: '',
							batchNum: '',
							pubSysCode: '',
							transCode:'',
							transName:'',
							regSysCode:''
						},
						pageNum: 1,
						pageSize: 5
					},
					
					dialogVisible:false,
					
			};
	
		},
		
		created() {
		  //this.getList();
		},
	
		
		
		methods: {
			closeDialog(){
				this.dialogVisible = false;
			},
			
			// showDialog(systemNo){
			// 	this.query.body.systemNo = systemNo;
			// 	this.getList();
			// 	this.type='add';
				
			// },
			
			showDialog(requireApply){
				this.systemNo = requireApply.regSysNo;
				this.id = requireApply.id;
				this.pubSysCode=requireApply.applySysNo;
				
				this.query.body.systemNo = requireApply.regSysNo;
				this.query.body.id = requireApply.id;
				this.query.body.pubSysCode=requireApply.applySysNo;
				
				this.query1.body.associatedRequirement = requireApply.qmsNo;
				this.query1.body.batchNum = requireApply.batchNum;
				this.query1.body.pubSysCode = requireApply.applySysNo;
				this.getList();
				this.type='add';
				
			},
			
			
			showDialog2(row,index) {
				this.type='update';
				this.index = index;
				// this.form = row;
				this.dialogVisible = true;
			
			},
			
			onSubmit() {
				this.getList();
			},
			
			onCommit(){
				this.dialogVisible = false;	
				this.$refs.listTable.selection.forEach((item,index)=>{
					//校验
					getSystemCallCheck({"regCode":item.busCode,"pubSysCode":item.systemNo,"regSysCode":item.regSysCode,"id":this.query.body.id,"requireType":'03',"transCode":item.transCode}).then(response => {
						if(response.data.code=='0000'){
							this.$emit("delApplySystemCall",item);
						}else{
							this.$message.error(item.transName+"："+response.data.message);
						}
						
					}).catch(error => {
						console.info("失败");
						console.info(error.message);
					});
				});
			},
			
			handleEdit(index,row){
				/* this.$router.push({name:'serviceDetails',query:{"busCode":row.busCode}}) */
				
				this.dialogVisible = false;
				
				if(this.type=='add'){
					this.$emit("addApplySystemCall",row);
				}else{
					this.$emit("updateApplySystemCall",row,this.index);
				}
				
			},
			
			reset() {
				this.query1.body.transCode = "";
				this.query1.body.transName = "";
				this.query1.body.regSysCode= "";
			},
			
			getList() {
				getServiceViewDel(this.query1).then(response => {
					this.list = response.data.extend.list;
					this.total = response.data.extend.total;
					this.dialogVisible = true;
				}).catch(error => {
					console.info("失败");
					console.info(error.message);
				});
			},
			
			currentChange(val){
				this.query.pageNum = val;
				this.query1.pageNum = val;
				this.getList();
			},
			sizeChange(val){
				this.query.pageSize = val;
				this.query1.pageSize = val;
				this.query.pageNum = 1;
				this.query1.pageNum = 1;
				this.getList();
			},
			
			getsystems1(val) {
				if (val != '') {
					this.systemList1 = this.systemListAll.filter(item => {
						return item.systemNo.indexOf(val) != -1 || item.systemName.indexOf(val) != -1;
					})
			
				} else {
					this.systemList1 = this.systemListAll;
				}
			
			},
			
		}
	}
</script>

<style>
</style>
